<?php

namespace App\Admin\Controllers;

use App\Models\FhLeraen;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use App\Http\Controllers\Controller;
use Dcat\Admin\Layout\Content;


class FhLeraenController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
     
      public function showHtml(Content $content)
    {
        $contents = FhLeraen::where('id',1)->value('content');
        $btn = "<a style='padding:10px 15px;background:#4b5ea0;color:#FFF;border-radius:5px;margin:10px;' href='/admin/lears/1/edit'>编辑教程</a>";
        $htmlContent = $btn.'<div style="background:#FFF; padding:20px;margin:0 10px;width:90%;min-height:80vh;margin-top:20px;">'.$contents.'</div>';
        return $content
            ->header('网站使用教程')
            ->body($htmlContent);
    }
     
    
     
  
    protected function form()
    {
        return Form::make(new FhLeraen(), function (Form $form) {
            $form->display('id');
            $form->editor('content');
            
            $form->tools(function (Form\Tools $tools) {
                $tools->append("<a href='/admin/lear' class='btn btn-sm'>返回</a> &nbsp;");
                // 去掉`列表`按钮
                $tools->disableList('true','');
                // 去掉`删除`按钮
                $tools->disableDelete();
                // 去掉`查看`按钮
                $tools->disableView();
            });
            
            // 跳转并提示成功信息
            $form->saved(function (Form $form) {
                return $form->response()->success('保存成功')->redirect('/lear');
            });

            $form->footer(function ($footer) {
                // 去掉`查看`checkbox
                $footer->disableViewCheck();
                // 去掉`继续编辑`checkbox
                $footer->disableEditingCheck();
                // 去掉`继续创建`checkbox
                $footer->disableCreatingCheck();
            });
            $form->display('updated_at');
        });
    }
}
